
using System;
using System.Collections;
using System.Web.UI.WebControls;

using Awaken.Framework;
using Nullables;

namespace Pubs.Domain.Entities
{
    public partial class Title : IEntity
    {
        protected static TitleBroker broker;
        public static TitleBroker Broker
        {
            get
            {
                if (broker == null)
                {
                    broker = new TitleBroker();
                }
                return broker;
            }
        }

        #region IEntity Members

        public string EntityID
        {
            get { return string.Empty; }
        }
        
        public string EntityName
        {
            get { return string.Empty; }
        }

        public void Save()
        {
            Broker.Save(this);
        }
        
        public void Delete()
        {
            Broker.Delete(this);
        }
        
        #endregion
    
        #region Constructor
        
        public Title()
        {
            // Default, no arg constructor.
        }
        
        #endregion
            
        #region Public Properties / Protected Fields
                        
        
        protected string _TitleId;
        public string TitleId
        {
            get{ return _TitleId; }
            set{ _TitleId=value; }
        }
        
        protected string _TitleColumn;
        public string TitleColumn
        {
            get{ return _TitleColumn; }
            set{ _TitleColumn=value; }
        }
        
        protected string _Type;
        public string Type
        {
            get{ return _Type; }
            set{ _Type=value; }
        }
        
        protected string _PubId;
        public string PubId
        {
            get{ return _PubId; }
            set{ _PubId=value; }
        }
        
        protected decimal? _Price;
        public decimal? Price
        {
            get{ return _Price; }
            set{ _Price=value; }
        }
        
        protected decimal? _Advance;
        public decimal? Advance
        {
            get{ return _Advance; }
            set{ _Advance=value; }
        }
        
        protected System.Int32? _Royalty;
        public System.Int32? Royalty
        {
            get{ return _Royalty; }
            set{ _Royalty=value; }
        }
        
        protected System.Int32? _YtdSales;
        public System.Int32? YtdSales
        {
            get{ return _YtdSales; }
            set{ _YtdSales=value; }
        }
        
        protected string _Notes;
        public string Notes
        {
            get{ return _Notes; }
            set{ _Notes=value; }
        }
        
        protected DateTime? _Pubdate;
        public DateTime? Pubdate
        {
            get{ return _Pubdate; }
            set{ _Pubdate=value; }
        }
        
        
        
        
        
        // Many-To-One: pub_info.pub_id
        protected Pubinfo _Pubinfo;
        public Pubinfo Pubinfo
        {
            get{ return _Pubinfo; }
            set{ _Pubinfo=value; }
        }
        
        // Many-To-One: publishers.pub_id
        protected Publisher _Publisher;
        public Publisher Publisher
        {
            get{ return _Publisher; }
            set{ _Publisher=value; }
        }
                
        
        
        // Many-To-Many: titleauthor
        protected IList _AuthorList;
        public IList AuthorList
        {
            get{ return _AuthorList; }
            set{ _AuthorList=value; }
        }
        
        
        #endregion
    }
    
    #region TitleBroker

    public partial class TitleBroker : IBroker
    {
        #region IBroker Members

        public Type EntityType
        {
            get { return typeof(Title); }
        }
        
        public Title GetByID(object id)
        {
            return (Title)Awaken.Framework.Gateway.GetByID(EntityType, id);
        }

        public IList GetAll()
        {
            return Awaken.Framework.Gateway.GetAll(EntityType);
        }

        public void Save(IEntity entity)
        {
            Awaken.Framework.Gateway.Save(entity);
        }
        
        public void Delete(IEntity entity)
        {
            Awaken.Framework.Gateway.Delete(entity);
        }
        
        #endregion
    }
    #endregion
}
